const app = getApp()
Page({
  onShareAppMessage() {
    return {
      title: 'scroll-view',
      path: 'page/component/pages/scroll-view/scroll-view'
    }
  },

  data: {
    mdetailMovie: {},
    activeNames: ['1']
  },

  onLoad: function (options) {
    wx.request({
      url: 'http://www.h5yjy.com/api/detailmovie?movieId=' + options.id,
      success: (res) => {
        var detailMovie = this.data.detailMovie;
        detailMovie = res.data.data.detailMovie;
        detailMovie.img = detailMovie.img.replace("w.h", "66.94")
        detailMovie.photos = detailMovie.photos.map(item => item.replace("w.h", "66.94"))
        this.setData({
          detailMovie
        });
      }
    })
  },

  onChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },


  upper(e) {
    console.log(e)
  },

  lower(e) {
    console.log(e)
  },

  scroll(e) {
    console.log(e)
  },

  scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },

  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },

  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },



  toVideo() {
    const detailMovie = this.data.detailMovie;
    const paramsStr = JSON.stringify({
      video: {
        videourl: detailMovie.videourl,
        videoImg: detailMovie.videoImg,
        videoName: detailMovie.videoName,
      },
      movieName: detailMovie.nm, //电影名称
      id: detailMovie.id, //电影ID
      version: detailMovie.version, //电影类型（3d、IMAX）
      release: detailMovie.pubDesc, //上映时间
      rt: detailMovie.rt, //电影上映时间
      wish: detailMovie.wish, //想看的人数
      globalReleased: detailMovie.globalReleased, //是否上映
      sc: detailMovie.sc, //评分
      showst: detailMovie.showst //判读“想看”、“预售”
    })
    wx.navigateTo({
      url: `../video-page/video-page?paramsStr=${paramsStr}`
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})